package cc.cix.gt.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * mysql 索引
 *
 * @author cix
 */
@Getter
@AllArgsConstructor
public enum IndexType {

    UK_DEPT_NAME("uk_dept_name", "部门名称不能重复"),
    UK_ROLE_NAME("uk_role_name", "角色名称不能重复"),
    UK_USER_MOBILE("uk_user_mobile", "手机号不能重复");

    private final String value;
    private final String desc;

    public static boolean isContains(String value) {
        for (IndexType dbIndexType : IndexType.values()) {
            if (value.contains(dbIndexType.getValue())) {
                return true;
            }
        }

        return false;
    }

    public static String getDescByValue(String value) {
        for (IndexType dbIndexType : IndexType.values()) {
            if (value.contains(dbIndexType.getValue())) {
                return dbIndexType.getDesc();
            }
        }

        return null;
    }

}
